package org.nobject.common.http;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;


/**
 * Cookie工具
 *
 * @author bianrongjun
 * @version 1.0
 */
public class CookieUtils {
	
	/**
	 * 获取Cookie
	 * @param request
	 * @param cookieName
	 * @return
	 */
	public static Cookie getCookie(HttpServletRequest request, String cookieName){
		if(request==null) return null;
		Cookie [] cookies=request.getCookies();
		if(cookies==null) return null;
		for (int i = 0; i < cookies.length; i++) {
			if(cookies[i].getName().equals(cookieName)) return cookies[i];
		}
		return null;
	}
	
}
